<template>
  <div>
    {{title}}
    <button @click="sendDataHandler">传递元素非父</button>
    <input type="text" v-model="message" @change="mesChange">
  </div>
</template>

<script>
  export default {
    name: "watch",
    data() {
      return {
        message: ''
      }
    },
    methods: {
      sendDataHandler() {
        this.$emit('myEvent', 'son data')
      },
      mesChange(val) {
        console.log(val);
        this.$emit('myChange', this.message)
      }
    },
    props: {
      title: {
        type: String,
        default: 'hello'
      }
    }
  }
</script>

<style>
</style>
